package com.mystudy.leetcode.problem.other.p_709;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author 周志龙
 * @Email 15216876513@163.com
 * @Date on 2019/7/10 21:47
 * @Description 转换成小写字母
 */
public class Solution {
    private static final Logger LOGGER = LoggerFactory.getLogger(Solution.class);


    @Test
    public void test(){
        String str = toLowerCase("AFrdG");
        LOGGER.debug("str = [ {} ]",str);
    }

    public String toLowerCase(String str) {
        char[] chars = str.toCharArray();
        int m =  'A'-'a';
        for (int i = 0; i < chars.length; i++) {
            if(chars[i] >= 'A' && chars[i]<='Z'){
                chars[i] = (char) (chars[i]-m);
            }
        }
        return new String(chars);
    }
}
